package com.heyige.dto;

import java.time.LocalDateTime;
import java.util.List;

import com.heyige.entity.PromptTemplate;
import io.swagger.v3.oas.annotations.media.Schema;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;

@Data
@Schema(description = "提示词模板相关数据传输对象")
public class PromptTemplateDto {
    
    @Schema(description = "添加模板请求")
    public static class AddRequest {
        @Schema(description = "标题", example = "写作助手", requiredMode = Schema.RequiredMode.REQUIRED)
        @NotBlank(message = "标题不能为空")
        @Size(max = 100, message = "标题长度不能超过100")
        private String title;
        
        @Schema(description = "描述", example = "帮助用户进行写作创作的模板")
        @Size(max = 500, message = "描述长度不能超过500")
        private String description;
        
        @Schema(description = "分类", example = "写作", requiredMode = Schema.RequiredMode.REQUIRED)
        @NotBlank(message = "分类不能为空")
        @Size(max = 50, message = "分类长度不能超过50")
        private String category;
        
        @Schema(description = "模板类型", example = "GENERAL", requiredMode = Schema.RequiredMode.REQUIRED)
        @NotNull(message = "类型不能为空")
        private PromptTemplate.TemplateType type = PromptTemplate.TemplateType.GENERAL;
        
        @Schema(description = "模板内容", example = "请帮我写一篇关于{主题}的文章", requiredMode = Schema.RequiredMode.REQUIRED)
        @NotBlank(message = "内容不能为空")
        private String content;
        
        @Schema(description = "变量", example = "主题,字数,风格")
        @Size(max = 1000, message = "变量长度不能超过1000")
        private String variables;
        
        @Schema(description = "标签", example = "写作,创作,文章")
        @Size(max = 500, message = "标签长度不能超过500")
        private String tags;
        
        @Schema(description = "是否公开", example = "true")
        private Boolean isPublic = true;
        
        @Schema(description = "排序顺序", example = "0")
        private Integer sortOrder = 0;
        
        // Getters and Setters
        public String getTitle() {
            return title;
        }
        
        public void setTitle(String title) {
            this.title = title;
        }
        
        public String getDescription() {
            return description;
        }
        
        public void setDescription(String description) {
            this.description = description;
        }
        
        public String getCategory() {
            return category;
        }
        
        public void setCategory(String category) {
            this.category = category;
        }
        
        public PromptTemplate.TemplateType getType() {
            return type;
        }
        
        public void setType(PromptTemplate.TemplateType type) {
            this.type = type;
        }
        
        public String getContent() {
            return content;
        }
        
        public void setContent(String content) {
            this.content = content;
        }
        
        public String getVariables() {
            return variables;
        }
        
        public void setVariables(String variables) {
            this.variables = variables;
        }
        
        public String getTags() {
            return tags;
        }
        
        public void setTags(String tags) {
            this.tags = tags;
        }
        
        public Boolean getIsPublic() {
            return isPublic;
        }
        
        public void setIsPublic(Boolean isPublic) {
            this.isPublic = isPublic;
        }
        
        public Integer getSortOrder() {
            return sortOrder;
        }
        
        public void setSortOrder(Integer sortOrder) {
            this.sortOrder = sortOrder;
        }
    }
    
    @Schema(description = "更新模板请求")
    public static class UpdateRequest {
        @Schema(description = "标题", example = "写作助手")
        @Size(max = 100, message = "标题长度不能超过100")
        private String title;
        
        @Schema(description = "描述", example = "帮助用户进行写作创作的模板")
        @Size(max = 500, message = "描述长度不能超过500")
        private String description;
        
        @Schema(description = "分类", example = "写作")
        @Size(max = 50, message = "分类长度不能超过50")
        private String category;
        
        @Schema(description = "模板类型", example = "GENERAL")
        private PromptTemplate.TemplateType type;
        
        @Schema(description = "模板内容", example = "请帮我写一篇关于{主题}的文章")
        private String content;
        
        @Schema(description = "变量", example = "主题,字数,风格")
        @Size(max = 1000, message = "变量长度不能超过1000")
        private String variables;
        
        @Schema(description = "标签", example = "写作,创作,文章")
        @Size(max = 500, message = "标签长度不能超过500")
        private String tags;
        
        @Schema(description = "是否公开", example = "true")
        private Boolean isPublic;
        
        @Schema(description = "排序顺序", example = "0")
        private Integer sortOrder;
        
        // Getters and Setters
        public String getTitle() {
            return title;
        }
        
        public void setTitle(String title) {
            this.title = title;
        }
        
        public String getDescription() {
            return description;
        }
        
        public void setDescription(String description) {
            this.description = description;
        }
        
        public String getCategory() {
            return category;
        }
        
        public void setCategory(String category) {
            this.category = category;
        }
        
        public PromptTemplate.TemplateType getType() {
            return type;
        }
        
        public void setType(PromptTemplate.TemplateType type) {
            this.type = type;
        }
        
        public String getContent() {
            return content;
        }
        
        public void setContent(String content) {
            this.content = content;
        }
        
        public String getVariables() {
            return variables;
        }
        
        public void setVariables(String variables) {
            this.variables = variables;
        }
        
        public String getTags() {
            return tags;
        }
        
        public void setTags(String tags) {
            this.tags = tags;
        }
        
        public Boolean getIsPublic() {
            return isPublic;
        }
        
        public void setIsPublic(Boolean isPublic) {
            this.isPublic = isPublic;
        }
        
        public Integer getSortOrder() {
            return sortOrder;
        }
        
        public void setSortOrder(Integer sortOrder) {
            this.sortOrder = sortOrder;
        }
    }
    
    @Schema(description = "模板响应")
    public static class TemplateResponse {
        @Schema(description = "模板ID", example = "1")
        private Long id;
        
        @Schema(description = "标题", example = "写作助手")
        private String title;
        
        @Schema(description = "描述", example = "帮助用户进行写作创作的模板")
        private String description;
        
        @Schema(description = "分类", example = "写作")
        private String category;
        
        @Schema(description = "模板类型", example = "GENERAL")
        private PromptTemplate.TemplateType type;
        
        @Schema(description = "模板内容", example = "请帮我写一篇关于{主题}的文章")
        private String content;
        
        @Schema(description = "变量", example = "主题,字数,风格")
        private String variables;
        
        @Schema(description = "标签", example = "写作,创作,文章")
        private String tags;
        
        @Schema(description = "是否公开", example = "true")
        private Boolean isPublic;
        
        @Schema(description = "用户ID", example = "1")
        private Long userId;
        
        @Schema(description = "使用次数", example = "10")
        private Integer usageCount;
        
        @Schema(description = "排序顺序", example = "0")
        private Integer sortOrder;
        
        @Schema(description = "创建时间", example = "2024-01-01T10:00:00")
        private LocalDateTime createdAt;
        
        @Schema(description = "更新时间", example = "2024-01-01T12:00:00")
        private LocalDateTime updatedAt;
        
        // Getters and Setters
        public Long getId() {
            return id;
        }
        
        public void setId(Long id) {
            this.id = id;
        }
        
        public String getTitle() {
            return title;
        }
        
        public void setTitle(String title) {
            this.title = title;
        }
        
        public String getDescription() {
            return description;
        }
        
        public void setDescription(String description) {
            this.description = description;
        }
        
        public String getCategory() {
            return category;
        }
        
        public void setCategory(String category) {
            this.category = category;
        }
        
        public PromptTemplate.TemplateType getType() {
            return type;
        }
        
        public void setType(PromptTemplate.TemplateType type) {
            this.type = type;
        }
        
        public String getContent() {
            return content;
        }
        
        public void setContent(String content) {
            this.content = content;
        }
        
        public String getVariables() {
            return variables;
        }
        
        public void setVariables(String variables) {
            this.variables = variables;
        }
        
        public String getTags() {
            return tags;
        }
        
        public void setTags(String tags) {
            this.tags = tags;
        }
        
        public Boolean getIsPublic() {
            return isPublic;
        }
        
        public void setIsPublic(Boolean isPublic) {
            this.isPublic = isPublic;
        }
        
        public Long getUserId() {
            return userId;
        }
        
        public void setUserId(Long userId) {
            this.userId = userId;
        }
        
        public Integer getUsageCount() {
            return usageCount;
        }
        
        public void setUsageCount(Integer usageCount) {
            this.usageCount = usageCount;
        }
        
        public Integer getSortOrder() {
            return sortOrder;
        }
        
        public void setSortOrder(Integer sortOrder) {
            this.sortOrder = sortOrder;
        }
        
        public LocalDateTime getCreatedAt() {
            return createdAt;
        }
        
        public void setCreatedAt(LocalDateTime createdAt) {
            this.createdAt = createdAt;
        }
        
        public LocalDateTime getUpdatedAt() {
            return updatedAt;
        }
        
        public void setUpdatedAt(LocalDateTime updatedAt) {
            this.updatedAt = updatedAt;
        }
    }
    
    @Schema(description = "处理结果")
    public static class ProcessResult {
        @Schema(description = "模板ID", example = "1")
        private Long templateId;
        
        @Schema(description = "模板标题", example = "写作助手")
        private String templateTitle;
        
        @Schema(description = "原始内容", example = "请帮我写一篇关于{主题}的文章")
        private String originalContent;
        
        @Schema(description = "处理后内容", example = "请帮我写一篇关于AI的文章")
        private String processedContent;
        
        @Schema(description = "变量信息列表")
        private List<VariableInfo> variables;
        
        // Getters and Setters
        public Long getTemplateId() {
            return templateId;
        }
        
        public void setTemplateId(Long templateId) {
            this.templateId = templateId;
        }
        
        public String getTemplateTitle() {
            return templateTitle;
        }
        
        public void setTemplateTitle(String templateTitle) {
            this.templateTitle = templateTitle;
        }
        
        public String getOriginalContent() {
            return originalContent;
        }
        
        public void setOriginalContent(String originalContent) {
            this.originalContent = originalContent;
        }
        
        public String getProcessedContent() {
            return processedContent;
        }
        
        public void setProcessedContent(String processedContent) {
            this.processedContent = processedContent;
        }
        
        public List<VariableInfo> getVariables() {
            return variables;
        }
        
        public void setVariables(List<VariableInfo> variables) {
            this.variables = variables;
        }
    }
    
    @Schema(description = "变量信息")
    public static class VariableInfo {
        @Schema(description = "变量名", example = "主题")
        private String name;
        
        @Schema(description = "是否找到", example = "true")
        private Boolean found = false;
        
        @Schema(description = "是否已替换", example = "true")
        private Boolean replaced = false;
        
        // Getters and Setters
        public String getName() {
            return name;
        }
        
        public void setName(String name) {
            this.name = name;
        }
        
        public Boolean getFound() {
            return found;
        }
        
        public void setFound(Boolean found) {
            this.found = found;
        }
        
        public Boolean getReplaced() {
            return replaced;
        }
        
        public void setReplaced(Boolean replaced) {
            this.replaced = replaced;
        }
    }
}